// 父类 | 基类
class Animal {
  readonly name: string;
  age: number;
  readonly sex: "公" | "母";
  constructor(name: string, age: number, sex: "公" | "母") {
    this.name = name;
    this.age = age;
    this.sex = sex;
  }
}

// 子类 | 派生类
class Pig extends Animal {
  constructor(age: number, sex: "公" | "母") {
    super("猪", age, sex);
  }
  say() {
    console.log("嗝嗝嗝~");
  }
}

// 子类 | 派生类
class Dog extends Animal {
  constructor(age: number, sex: "公" | "母") {
    super("狗", age, sex);
  }
  say() {
    console.log("汪汪汪~");
  }
}

const cat = new Animal("猫", 3, "母");

const dog = new Dog(2, "公");
const pig = new Pig(3, "公");

//
class Father {
  age: number = 40;
  // 属性“money”受保护，只能在类“Father”及其子类中访问
  protected money: number = 10000;
  // 属性“litteMoney”为私有属性，只能在类“Father”中访问。
  private _litteMoney: number = 100;

  constructor() {
    this.money = 10;
    this._litteMoney = 10;
  }
  // 访问器
  get litteMoney() {
    //
    return this._litteMoney;
  }

  set litteMoney(value) {
    this._litteMoney = value;
  }
}

class Son extends Father {
  constructor() {
    super();
    // this.litteMoney
  }
  makeMoney() {
    this.money += 10;
  }
  consumeMoney() {
    this.money -= 1000;
  }
}

const s1 = new Son();
s1.litteMoney = 999;
console.log(s1);

// console.log(s1.litteMoney);

// s1.money -= 10000


// ***************123123*****************************
